package cn.czk.demo;

import dev.langchain4j.data.embedding.Embedding;
import dev.langchain4j.model.openai.OpenAiEmbeddingModel;
import dev.langchain4j.model.output.Response;
import dev.langchain4j.model.zhipu.ZhipuAiEmbeddingModel;

import java.time.Duration;

public class VectorDemo {

    public static void main(String[] args) {

//        OpenAiEmbeddingModel embeddingModel = ZhipuAiEmbeddingModel.builder()
//                .apiKey("53e452feb1164ec8a6c9cd9112a37d60.xTOwz9t4NIZuYTYb")
//                .modelName("glm-4")
//                .baseUrl("https://open.bigmodel.cn/api/paas/v4/")
//                .build();

        ZhipuAiEmbeddingModel model = ZhipuAiEmbeddingModel.builder()
                .apiKey("53e452feb1164ec8a6c9cd9112a37d60.xTOwz9t4NIZuYTYb")
                .logRequests(true)
                .logResponses(true)
                .maxRetries(1)
                .callTimeout(Duration.ofSeconds(60))
                .connectTimeout(Duration.ofSeconds(60))
                .writeTimeout(Duration.ofSeconds(60))
                .readTimeout(Duration.ofSeconds(60))
                .build();


        Response<Embedding> embed = model.embed("你好，我是程志琨");
        System.out.println(embed.content().toString());
        System.out.println(embed.content().vector().length);

    }

}
